package com.yichen.entity;

import com.yichen.Utils;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Classname QuerySearch
 * @Description
 * @Author caozhenhao001
 * @Date 2024/6/6
 * @Version
 */


@Data
public class QueryCondition {

    private String name;   // 条件查询的属性名, 可能重复，比如查询条件为大于...且小于...，这时queryConditionList中会又两条name相同的数据
    private JavaTypeEnum type;   // 属性类型
    private QueryTypeEnum queryConditionType;  // 查询条件类型，等值、区间、模糊
    private String limitName;      // 范围查询时（如nameInTable > limitName）的比较条件的属性名，queryCondition不能重复
    private String nameInTable;    // name对应table中的字段名，为下划线命名

    public QueryCondition(String name, JavaTypeEnum type, QueryTypeEnum queryConditionType, String limitName) {
        this.name = name;
        this.type = type;
        this.queryConditionType = queryConditionType;
        this.limitName = limitName;
        this.nameInTable = Utils.convertCamelToSnake(name);
    }

    public QueryCondition(String name, JavaTypeEnum type, QueryTypeEnum queryConditionType, String limitName, String nameInTable) {
        this.name = name;
        this.type = type;
        this.queryConditionType = queryConditionType;
        this.limitName = limitName;
        this.nameInTable = nameInTable;
    }

    public QueryCondition(String name, JavaTypeEnum type, QueryTypeEnum queryConditionType) {
        this.name = name;
        this.type = type;
        this.queryConditionType = queryConditionType;
        this.nameInTable = Utils.convertCamelToSnake(name);
        this.limitName = name;
    }
}
